package com.example.shiwuyouproject.ui.fragment.my.activity

import androidx.lifecycle.Observer
import com.example.shiwuyouproject.base.BaseVmActivity
import com.example.shiwuyouproject.databinding.ActivityAuthenticationcenterBinding
import com.example.shiwuyouproject.ui.fragment.my.activity.viewmodel.AuthenticationCenterViewModel
import com.example.shiwuyouproject.ui.my.bean.PersonalInformationBean
import com.example.shiwuyouproject.utils.ActStartUtils

/**
 * 认证中心
 */
class AuthenticationCenterActivity :
    BaseVmActivity<ActivityAuthenticationcenterBinding, AuthenticationCenterViewModel>() {
    override fun viewModelClass(): Class<AuthenticationCenterViewModel> =
        AuthenticationCenterViewModel::class.java

    override fun getViewBinding(): ActivityAuthenticationcenterBinding {
        return ActivityAuthenticationcenterBinding.inflate(layoutInflater)
    }

    override fun initView() {
        mBinding.myTitleBar.tvTitle.text = "认证中心"
    }

    override fun initData() {

    }

    override fun onResume() {
        super.onResume()
        mViewModel.getRealNameAuthenticationData()
    }

    override fun setListener() {
        mBinding.myTitleBar.tvBack.setOnClickListener { finish() }
        mBinding.clShiMinRenZheng.setOnClickListener { //实名认证
            ActStartUtils.startAct(this, RealNameAuthenticationActivity::class.java)
        }
        mBinding.clJiaoShi.setOnClickListener { //教师资格认证
            ActStartUtils.startAct(this, TeacherCertificationActivity::class.java)
        }
        mBinding.clXueLi.setOnClickListener { //最高学历认证
            ActStartUtils.startAct(this, AcademicCertificationActivity::class.java)
        }
    }

    override fun observe() {
        mViewModel.getGenRenStatus.observe(this,  Observer<PersonalInformationBean>{
            if (it.idfront.isNotEmpty() && it.idback.isNotEmpty()) {
                mBinding.tvShiMin.isSelected = true
                mBinding.tvShiMin.text = "已认证"
            } else {
                mBinding.tvShiMin.isSelected = false
                mBinding.tvShiMin.text = "未认证"
            }
            if (it.teachno.isNotEmpty() && it.teachimg.isNotEmpty()) {
                mBinding.tvJiaoShi.isSelected = true
                mBinding.tvJiaoShi.text = "已认证"
            } else {
                mBinding.tvJiaoShi.isSelected = false
                mBinding.tvJiaoShi.text = "未认证"
            }
            if (it.eduend_time.isNotEmpty() && it.eduno.isNotEmpty()) {
                mBinding.tvXueLi.isSelected = true
                mBinding.tvXueLi.text = "已认证"
            } else {
                mBinding.tvXueLi.isSelected = false
                mBinding.tvXueLi.text = "未认证"
            }

        })

    }
}